home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DDJMAG
/
DDJ9203.ZIP
/
OOPASM.ZIP
/
STRINGS.MAC
< prev
next >
Wrap
Text File
|
1990-12-14
|
5KB
|
226 lines
COMMENT %
============================================================================
Displays a character by using DOS function call.
===========================================================================%
prtChar MACRO Char,Attr,Page,Count
IFNB <Page> ;If given display page
mov bh,Page ;Pass it in bh
ELSE
mov bh,0 ;Otherwise use display page zero
ENDIF
IFDIF <Attr>,<bl>
mov bl,Attr ;Pass attribute in bl
ENDIF
mov ah,9 ;Pass service number in ah
IFDIF <Char>,<al>
mov al,Char ;Pass character in al
ENDIF
IFNB <Count> ;If given character count
mov cx,Count ;Pass number of chars to write in cx
ELSE
mov cx,1 ;Otherwise print one char
ENDIF
int 10h
IFNB <Count>
cursorRight
ENDIF
ENDM
COMMENT %
============================================================================
Writes an ASCIIZ string to the screen.
===========================================================================%
prtStrg MACRO StringAddr,Attr,Page
LOCAL ps1,ps2
pushf
cld ;Clear direction flag
IFDIF <StringAddr>,<si>
mov si,StringAddr ;Get string address pointer
ENDIF
ps1: lodsb ;Load a char into al
cmp al,0 ;End of string yet?
je ps2 ;Yes, so return
IFNB <Page> ;If given display page
mov bh,Page ;Pass it in bh
ELSE
mov bh,0 ;Otherwise use display page zero
ENDIF
IFDIF <Attr>,<bl>
mov bl,Attr ;Pass attribute in bl
ENDIF
mov ah,9 ;Pass service number in ah
mov cx,1 ;Pass number of chars in cx
int 10h
cursorRight
jmp ps1
ps2: popf
ENDM
COMMENT %
============================================================================
Displays a character by writing to video memory.
===========================================================================%
disChar MACRO Row,Col,Attr,Char
LOCAL dchr1,dchr2,dchr3,dchr4
IFDIF <Row>,<al>
mov al,Row
ENDIF
mov cl,160 ;Get bytes/row
mul cl ;ax = al * cl
mov di,ax ;Save sub-total
IFDIF <Col>,<al>
mov al,Col
ENDIF
mov cl,2 ;Get bytes/column
mul cl ;ax = al * cl
add di,ax ;Get total # of bytes
IF Snow
mov dx,03DAh ;Status port addr
cli ;Disable interrupts
dchr1: in al,dx ;Read status port
and al,1 ;Wait for horz retrace to end
jnz dchr2 ;If in progress
dchr2: in al,dx ;Read status port
and al,1 ;Wait for horz retrace
jz dchr2 ;To start
ENDIF
mov Bptr es:[di],Char ;Move char into video seg
IF Snow
sti ;Enable interrupts
ENDIF
IF Snow
mov dx,03DAh ;Status port addr
cli ;Disable interrupts
dchr3: in al,dx ;Read status port
and al,1 ;Wait for horz retrace to end
jnz dchr3 ;If in progress
dchr4: in al,dx ;Read status port
and al,1 ;Wait for horz retrace
jz dchr4 ;To start
ENDIF
mov Bptr es:[di+1],Attr ;Move attribute into video seg
IF Snow
sti ;Enable interrupts
ENDIF
ENDM
COMMENT %
============================================================================
Displays an ASCIIZ string by writing to video memory.
===========================================================================%
disStrg MACRO Row,Col,Attr,StringAddr
LOCAL dss1,dss2,dss3,dss4,dss5,dss6
IFDIF <Row>,<al>
mov al,Row
ENDIF
mov cl,160 ;Get bytes/row
mul cl ;ax = al * cl
mov di,ax ;Save sub-total
IFDIF <Col>,<al>
mov al,Col
ENDIF
mov cl,2 ;Get bytes/column
mul cl ;ax = al * cl
add di,ax ;Get total # of bytes
IFDIF <Attr>,<bl>
mov bl,Attr
ENDIF
IFDIF <StringAddr>,<si>
mov si,StringAddr
ENDIF
dss1: lodsb ;Load char
zero al,dss2 ;Zero? - Exit
mov bh,al ;Save char
IF Snow
mov dx,03DAh ;Status port addr
cli ;Disable interrupts
dss3: in al,dx ;Read status port
and al,1 ;Wait for horz retrace to end
jnz dss3 ;If in progress
dss4: in al,dx ;Read status port
and al,1 ;Wait for horz retrace
jz dss4 ;To start
ENDIF
mov Bptr es:[di],bh ;Move char into video seg
IF Snow
sti ;Enable interrupts
ENDIF
inc di ;Point to attribute location
IF Snow
mov dx,03DAh ;Status port addr
cli ;Disable interrupts
dss5: in al,dx ;Read status port
and al,1 ;Wait for horz retrace to end
jnz dss5 ;If in progress
dss6: in al,dx ;Read status port
and al,1 ;Wait for horz retrace
jz dss6 ;To start
ENDIF
mov Bptr es:[di],bl ;Move attribute into video seg
IF Snow
sti ;Enable interrupts
ENDIF
inc di ;Point to next char location
jmp dss1
dss2:
ENDM
COMMENT %
============================================================================
Displays a given attribute by writing to video memory.
===========================================================================%
disAttr MACRO R1,C1,C2,Attr
LOCAL dsa1
IFDIF <ch>,<C2>
mov ch,C2
ENDIF
sub ch,C1 ;Get number of columns
IFDIF <al>,<R1>
mov al,R1
ENDIF
mov cl,160 ;Get bytes/row
mul cl ;ax = al * cl
mov di,ax ;Save sub-total
IFDIF <al>,<C1>
mov al,C1
ENDIF
mov cl,2 ;Get bytes/column
mul cl ;ax = al * cl
add di,ax ;Get total # of bytes
IFDIF <bl>,<Attr>
mov bl,Attr
ENDIF
mov cl,ch ;Set up loop counter
xor ch,ch
dsa1: mov Bptr es:[di+1],bl ;Move attribute into video seg
add di,2 ;Point to next char location
loop dsa1
ENDM